home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / ptv2n1.arc / HAXBP.ASM < prev    next >
Assembly Source File  |  1991-03-26  |  2KB  |  53 lines

  1. ; Copyright 1990, Tim Farley
  2. ;
  3. ; NOTE:  Don't use this technique unless you have more than 128
  4. ;        bytes of local variables!
  5. ;
  6. xproc   PROC NEAR
  7. ;
  8. ; First, declare our local variables via a structure
  9. ;
  10. xloc    STRUC
  11. large1   dw   50 dup(?)            ; a large (100-byte) array
  12. large2   dw   50 dup(?)            ; another one
  13. word1    dw   ?                    ; a word
  14. word2    dw   ?                    ; another word
  15. xloc    ENDS
  16.  
  17. xlen    equ  SIZE xloc             ; size of our locals 
  18. xbpadj  equ  xlen-128              ; how far we will move sweet spot
  19. xlocals equ  [bp-128]              ; use this to access locals
  20. ;
  21. ; Now, the actual code
  22. ;
  23.          push bp              ; Standard prologue
  24.          mov  bp,sp
  25.          sub  sp,xlen         ; allocate space for locals
  26. ;
  27. ; Reference passed parameters declared with ARG here, before we adjust
  28. ; the value of BP to move the sweet spot.
  29. ;
  30.          sub  bp,xbpadj       ; move the sweet spot
  31.  
  32. ;
  33. ; Example local references
  34. ;
  35.          mov  si,xlocals.large1
  36.          mov  ax,xlocals.word1
  37.  
  38.          mov  bx,xlocals.large2[di]
  39.  
  40. ;
  41. ; Make sure to clean up stack
  42. ;
  43.          add  bp,xbpadj       ; put bp back where we found it
  44. ;
  45. ; You can reference passed parameters declared with ARG again 
  46. ; here if you need to alter them for return to the caller.
  47. ;
  48.          mov  sp,bp           ; Standard epilogue
  49.          pop  bp
  50.          ret                  ; Be sure to pop arguments if you need to
  51.  
  52. xproc   ENDP
  53.